package com.emptyMe.basic.utils;

import lombok.Data;

public class AjaxResult {
    private Integer code = 20000;
    private Boolean success = true;
    private String msg = "操作成功";
    private Object data;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public AjaxResult(Boolean success) {
        this.success = success;
    }


    public AjaxResult(Boolean success, String msg) {
        this.success = success;
        this.msg = msg;
    }

    public AjaxResult(Boolean success, Object data) {
        this.data = data;
    }

    public AjaxResult(Boolean success, String msg, Object data) {
        this.success = success;
        this.msg = msg;
        this.data = data;
    }

    /**
     * success:true默认值
     *
     * @return
     */
    public static AjaxResult me() {
        return new AjaxResult(true);
    }

    /**
     * @param success 无默认值
     * @param msg
     * @return
     */
    public static AjaxResult me(boolean success, String msg) {
        return new AjaxResult(success, msg);
    }

    /**
     * success:true默认值
     *
     * @param data 数据
     * @return
     */
    public static AjaxResult me(Object data) {
        return new AjaxResult(true, data);
    }

    /**
     * @param success 无默认值
     * @param msg     错误消息
     * @param data    数据
     * @return
     */
    public static AjaxResult me(boolean success, String msg, Object data) {
        return new AjaxResult(success, msg, data);
    }

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "AjaxResult{" +
                "success=" + success +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
